<!--
 * @Description: 精英任务领取列表入口
 * @Author: liyujie
 * @Date: 2021/05/15
 * @Last Modified by: liyujie
 * @Last Modified time: 2021/05/15
-->
<template>
    <section class="wrapper">
        <div class="content-wrapper">
            <!-- header -->
            <div class="header">
                <div class="header-title">
                    任务领取列表：
                </div>
                <div class="tab-view">
                    <div
                        v-for="item in tabList"
                        :key="item.id"
                        class="tab-item"
                        :class="{'active': active === item.id}"
                        @click="handleTabClick(item.id)"
                    >
                        {{ item.name }}
                    </div>
                </div>
            </div>
            <!-- /header -->
            <normal-task-receive-list v-if="active === 'normal'"/>
            <dorm-task-receive-list v-if="active === 'dorm'"/>
            <multiple-task-receive-list v-if="active === 'multiple'"/>
            <gradient-task-receive-list v-if="active === 'gradient'"/>
        </div>
    </section>
</template>

<script>
import { back } from '@/mixin/back';
import NormalTaskReceiveList from './normal-task-receive-list';
import DormTaskReceiveList from './dorm-task-receive-list';
import MultipleTaskReceiveList from './multiple-task-receive-list';
import GradientTaskReceiveList from './gradient-task-receive-list';

export default {
    name: 'Index',
    mixins: [back],
    components: {
        NormalTaskReceiveList,
        DormTaskReceiveList,
        MultipleTaskReceiveList,
        GradientTaskReceiveList
    },
    data() {
        return {
            // normal普通任务 dorm寝室推广 multiple多奖励任务 gradient梯度任务
            active: 'normal',
            tabList: [
                { id: 'normal', name: '普通任务' },
                { id: 'dorm', name: '寝室推广任务' },
                { id: 'multiple', name: '多奖励任务' },
                { id: 'gradient', name: '梯度任务' }
            ]
        };
    },
    mounted() {
        this.$store.commit('SET_HEADER', [{ title: "APP后台"},{ title: "工作"},{title: '平台标准任务'}, {title: '任务领取列表'}]);

        this.active = this.$route.query.active || 'normal';
    },
    methods: {
        handleTabClick(active) {
            this.active = active;
            this.$router.push({
                query: {
                    active
                },
            });
        }
    }
};
</script>

<style lang="less" scoped>
.wrapper {
    width: 100%;

    .content-wrapper {
        display: flex;
        height: calc(100% - 24px);
        flex-direction: column;
        position: relative;
        margin: 12px;
        background: #fff;
        box-sizing: border-box;
        .header {
            height: 78px;
            display: flex;
            align-items: center;
            border-bottom: 1px solid #F0F2F5;
            padding: 0 35px;
            .header-title {
                font-size: 20px;
                font-family: PingFangSC-Medium, PingFang SC;
                font-weight: 500;
                color: #333333;
                line-height: 20px;
                position: relative;
                margin-right: 12px;

                &::before {
                    content: '';
                    position: absolute;
                    width: 3px;
                    height: 20px;
                    background: #1890FF;
                    left: -8px;
                    top: 50%;
                    transform: translateY(-50%);
                }
            }
            .tab-view {
                display: flex;
                .tab-item {
                    height: 30px;
                    padding: 8px 12px;
                    background: #FFFFFF;
                    border-radius: 4px;
                    border: 1px solid #F0F2F5;
                    font-size: 14px;
                    font-family: PingFangSC-Medium, PingFang SC;
                    font-weight: 500;
                    color: #999999;
                    display: flex;
                    align-items: center;
                    justify-content: center;
                    margin-right: 32px;
                    cursor: pointer;
                    transition: all .2s;
                    &.active {
                        background: #20A0FF;
                        color: #fff;
                    }
                }
            }
        }
    }
}
/deep/ .el-table {
    th {
        background: #f2f2f2!important;
        font-size: 14px!important;
        font-family: PingFangSC-Medium, PingFang SC!important;
        font-weight: 500!important;
        color: #333333!important;
        height: 44px!important;
    }
}
</style>

